package cn.t17.appsys.controller;

import cn.t17.appsys.dto.CommonResponse;

/**
 * BaseController class
 *
 * @author Administrator
 * @date 2021/9/16
 */
public class BaseController {

    public <T> CommonResponse success(String message){
        return success(null,message);
    }

    public <T> CommonResponse success(T  data){
        return success(data,null);
    }


    public <T> CommonResponse success(T data,String message){
        return build(0,data,message);
    }

    public <T> CommonResponse error(Integer code,String message){
        return build(code,null,message);
    }

    private  <T> CommonResponse build(Integer code,T  data,String message){
        CommonResponse<T> response = new CommonResponse<>();
        response.setCode(code);
        response.setData(data);
        response.setMessage(message);
        return response;
    }
}
